﻿@using Smartstore.Admin.Models.Customers

@model CustomerModel

@{
	var parentModel = ViewData["Parent"] as RuleSetModel;
	var usernamesEnabled = (bool)ViewData["UsernamesEnabled"];
}

<datagrid id="customer-preview-grid" 
		allow-resize="true" 
		allow-column-reordering="true" 
		allow-row-selection="false" 
		preserve-grid-state="true"
		max-height="800px"
		onrowclass="customerPreviewGrid_onRowClass">
	<datasource read="@Url.Action("PreviewList", new { id = parentModel.Id })" />
	<paging position="Bottom" show-size-chooser="true" />
	<columns>
		<column for="Id" halign="center" width="auto" type="string" />
		<column for="Email" hideable="false">
            <display-template>
                <div class="text-truncate"><a :href="item.row.EditUrl" class="text-truncate" target="_blank">{{ item.value }}</a></div>
            </display-template>
		</column>
		@if (usernamesEnabled)
		{
			<column for="Username" />
		}
		<column for="FullName" />
		<column for="Active" halign="center" />
		<column for="CreatedOn" />
		<column for="LastActivityDate" />
	</columns>
</datagrid>

<script sm-target-zone="scripts" data-origin="customer-preview-grid">
    function customerPreviewGrid_onRowClass(row) {
        return { "text-muted": !row.Active };
    }
</script>